<template>
  <!-- 入库检任务清单 -->
  <p-card :bordered="false">
    <!-- 查询区域 -->
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <p-form layout="inline" @keyup.enter.native="searchQuery">
        <p-row :gutter="24">
          <p-col :xl="6" :lg="7" :md="8" :sm="24">
            <p-form-item label="送检单号">
              <p-input placeholder="请输入送检单号" v-model="queryParam.inspectBillno"></p-input>
            </p-form-item>
          </p-col>

          <p-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <p-button type="primary" @click="searchQuery" icon="search">查询</p-button>
              <p-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</p-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <p-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </p-col>
        </p-row>
      </p-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">


      <template v-if="cgButtonList && cgButtonList.length>0" v-for="(item,index) in cgButtonList">
        <p-button v-if=" item.optType=='js' && (item.groupTag == null || item.groupTag == '' )" :key=" 'cgbtn'+index "
                  @click="cgButtonJsHandler(item.buttonCode)" type="primary" :icon="item.buttonIcon">{{ item.buttonName }}
        </p-button>
        <p-button v-else-if=" item.optType=='action' && (item.groupTag == null || item.groupTag == '' )"
                  :key=" 'cgbtn'+index " @click="cgButtonActionHandler(item.buttonCode)" type="primary" :icon="item.buttonIcon">
          {{ item.buttonName }}</p-button>
      </template>

      <!-- 高级查询区域 -->
      <j-super-query :fieldList="fieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>

      <p-dropdown v-for="(item,index) in groupTag" :key="index">
        <p-button>
          {{item.name}}
          <p-icon type="down" />
        </p-button>
        <p-menu slot="overlay">
          <template v-for="(items,indexs) in item.data">
            <p-menu-item v-if=" items.optType=='js' " :key="indexs" @click="cgButtonJsHandler(items.buttonCode)">
              <p-icon :type="items.buttonIcon" />{{items.buttonName}}
            </p-menu-item>
            <p-menu-item v-else-if=" items.optType=='action' " :key="indexs"
                         @click="cgButtonActionHandler(items.buttonCode)">
              <p-icon :type="items.buttonIcon" />{{items.buttonName}}
            </p-menu-item>
          </template>
        </p-menu>
      </p-dropdown>

      <p-dropdown v-if="selectedRowKeys.length > 0">
        <p-menu slot="overlay">
          <p-menu-item key="1" @click="batchDel">
            <p-icon type="delete" />删除</p-menu-item>
        </p-menu>

      </p-dropdown>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> <a style="font-weight: 600"></a>
        <a style="margin-left: 24px"></a>

        <span style="float:right;">
              <a @click="handleExportXls('出厂检验任务清单')"><p-icon type="download" />导出</a>
                 <p-divider type="vertical" />
              <p-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
                 <a><p-icon type="import" />导入</a>
              </p-upload>
              <p-divider type="vertical" />
              <a @click="loadData()"><p-icon type="sync" />刷新</a>
              <p-divider type="vertical" />
                <p-popover title="自定义列" trigger="click" placement="leftBottom"  :overlay-style="getWidth">
                <template slot="content">
                  <p-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
                    <p-row>
                      <template v-for="(item,index) in defColumns">
                        <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                            <p-col :span="12"><p-checkbox :value="item.dataIndex">{{ item.title }}</p-checkbox></p-col>
                        </template>
                      </template>
                    </p-row>
                  </p-checkbox-group>
                </template>
                <a><p-icon type="setting" />自定义列</a>
              </p-popover>
            </span>
      </div>

      <!-- 表格 -->
      <p-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :scroll="tableScroll"
               :dataSource="dataSource" :pagination="ipagination" :loading="loading"
               :customRow="clickThenSelect" :rowClassName="setRowClassName" @change="handleTableChange">

        <template slot="inspectBillno" slot-scope="text,record">
          <a v-if="record.inspectStatus==1||record.inspectStatus==2" @click="inspectBillnoClick(record)">{{record.inspectBillno}}</a>
          <div v-else> {{record.inspectBillno}}</div>
        </template>

        <template slot="planExpedited" slot-scope="text,record">
          <div>
            <p-switch checked-children="是" un-checked-children="否" :checked="record.planExpedited==1?true:false"   @click="changePlanExpedited(record.id)"/>
          </div>
        </template>

        <template slot="inspectStatus" slot-scope="text,record">
          <!--<div v-if="text==1" >待检</div>
          <div v-else-if="text==2" >待整改</div>
          <div v-else-if="text==3" >检验完成</div>
-->

          <p-tag v-if="text==1"  color="blue" ><p-icon type="clock-circle" />待检</p-tag>
          <p-tag v-else-if="text==2" color="orange"><p-icon type="exclamation-circle" />待整改</p-tag>
          <p-tag v-else-if="text==3" color="green"><p-icon type="check-circle" />检验完成</p-tag>

        </template>

        <template slot="inspectResult" slot-scope="text,record">
          <!-- <div  :color="(record.status==3||record.status==4)?'red':'black'">{{ text }}</div>-->
          <div v-if="!text" >/</div>
          <p-tag v-else-if="text==1" color="green"><p-icon type="check-circle" />合格</p-tag>
          <p-tag v-else-if="text==2" color="red"><p-icon type="close-circle" />不合格</p-tag>
        </template>

      </p-table>
    </div>


    <p-drawer
            title="详情信息"
            placement="right"
            :width="980"
            :closable="false"
            :visible="drawerVisible"
            @close="drawerClose"
    >
      <p-divider orientation="left">
        主信息
      </p-divider>
      <p-descriptions bordered  size="small">
        <p-descriptions-item label="送检单号">
          {{this.baseInfoData.inspectBillno}}
        </p-descriptions-item>
        <p-descriptions-item label="发货工单号">
          {{this.baseInfoData.deliveryNumber}}
        </p-descriptions-item>
        <p-descriptions-item label="送检方式">
          {{this.baseInfoData.inspectMethod}}
        </p-descriptions-item>
        <p-descriptions-item label="销售单号">
          {{this.baseInfoData.salesOrder}}
        </p-descriptions-item>
        <p-descriptions-item label="产品编号">
          {{this.baseInfoData.mcode}}
        </p-descriptions-item>
        <p-descriptions-item label="产品名称">
          {{this.baseInfoData.mname}}
        </p-descriptions-item>
        <p-descriptions-item label="送检数量">
          {{this.baseInfoData.inspectQty}}
        </p-descriptions-item>
        <p-descriptions-item label="送检人">
          {{this.baseInfoData.sender}}
        </p-descriptions-item>
        <p-descriptions-item label="送检时间">
          {{this.baseInfoData.sendInspectDt}}
        </p-descriptions-item>
        <p-descriptions-item label="抽检方式">
          {{this.baseInfoData.samplingMethod}}
        </p-descriptions-item>
        <p-descriptions-item label="抽检数量">
          {{this.baseInfoData.samplingQty}}
        </p-descriptions-item>
        <p-descriptions-item label="检验次数">
          {{this.baseInfoData.verifyTimes}}
        </p-descriptions-item>
        <p-descriptions-item label="检验剩余时长">
          {{this.baseInfoData.remainingTime}}
        </p-descriptions-item>
        <p-descriptions-item label="检验时间">
          {{this.baseInfoData.inspectDt}}
        </p-descriptions-item>
        <p-descriptions-item label="检验人">
          {{this.baseInfoData.inspector}}
        </p-descriptions-item>

      </p-descriptions>

      <p-divider orientation="left">
        更多信息
      </p-divider>

      <p-collapse v-model="activeKey">
        <p-collapse-panel key="1" header="检验项目">
          <p-table
                  :columns="modal1InspectionColumns"
                  :data-source="baseInfoData.mesQcDeliInspectItemList"
                  class="components-table-demo-nested"
                  bordered
                  :expandIcon="expandIconOne"
                  style="margin-top:10px;"
          >
            <a slot="photoUrl" slot-scope="text">photoUrl</a>


            <p-table
                    slot="expandedRowRender"
                    slot-scope="text"
                    :columns="modal1InspectionInnerColumns"
                    :data-source="text.mesQcInspectProjectsList"
                    :pagination="false"

                    bordered
            >
            </p-table>


            <template slot="photoUrl" slot-scope="text,record">
              <!-- <p-button type="primary" icon="upload" :disabled="reviewVisible" @click="openPhUpBtn2(record)" >上传</p-button>-->
              <p-divider type="vertical" v-if="record.photoUrl&&record.photoUrl!=''"/>
              <p-button v-if="record.photoUrl&&record.photoUrl!=''" type="primary" icon="eye" @click="openPhReviewBtn2(record)">预览</p-button>
            </template>
          <!--  <template slot="photoUrl" slot-scope="text">
              <p-button>{{text.photoUrl}}</p-button>
            </template>-->


          </p-table>


          <p-modal v-model="phUpVisible2" title="图片上传" @ok="phUpSave2" okText="保存更改">
            <j-upload v-model="currentDetailPhObj" :trigger-change="true" :ismultiSelect="false"></j-upload>
          </p-modal>

          <div>
            <p-modal v-model="dPhVisible" title="图片预览(非图片文件无法预览-需下载)" :footer="null" :width="1000">
              <img :src="dPhUrl" class="myImg"/>
            </p-modal>
          </div>


        </p-collapse-panel>
        <p-collapse-panel key="2" header="送检产品明细">
          <p-table
                  :columns="inspectionProductsColumns"
                  :data-source="baseInfoData.proDetailsList"
                  class="components-table-demo-nested"
                  bordered
                  style="margin-top:10px;"
          >

          </p-table>
        </p-collapse-panel>
      </p-collapse>

    </p-drawer>



    <!-- 弹出窗 -->
    <Fx-compontens-modal @ok="modalFormOk"  ref="modalCompon" :getList="queryInfo" :title="title" :dictOptions="dictOptions"></Fx-compontens-modal>
  </p-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {api} from '@/api/manage'
  import JSuperQuery from '@/components/jeecg/JSuperQuery.vue'
  import { filterObj } from '@/utils/util'
  import MesQcDeliveryInspectTaskModal from './modules/MesQcDeliveryInspectTaskModal'
  import Vue from 'vue'
  import MesQcDeliInspectItemList from './MesQcDeliInspectItemList'
  import MesQcDeliInspectProductListList from './MesQcDeliInspectProductListList'
  import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import ButtonExpHandler from '@/components/jeecgbiz/modules/ButtonExpHandler'
  import { postAction,getAction,deleteAction } from '@/api/manage'
  import FxCompontensModal from "@/components/jeecgbiz/FxCompontensModal"
  import TesttableList from "../mesInfo/TesttableList";

  //高级查询modal需要参数
  const superQueryFieldList=[
    {
      value:'inspectBillno',
      text: '送检单号',
      type: 'string'
    },
    {
      value:'mcode',
      text: '产品编号',
      type: 'string'
    },
    {
      value:'mname',
      text: '产品名称',
      type: 'string'
    },
    {
      value:'inspectMethod',
      text: '送检方式',
      type: 'string'
    },
    {
      value:'deliveryNumber',
      text: '发货工单号',
      type: 'string'
    },
    {
      value:'salesOrder',
      text: '销售单号',
      type: 'String'
    },
    {
      value:'inspectQty',
      text: '送检数量',
      type: 'int'
    },
    {
      value:'samplingQty',
      text: '抽检数量',
      type: 'int'
    },
    {
      value:'sendInspectDt',
      text: '送检时间',
      type: 'Date'
    },
    {
      value:'remainingTime',
      text: '检验剩余时长',
      type: 'int'
    },
    {
      value:'sender',
      text: '送检人',
      type: 'string'
    },
    {
      value:'inspector',
      text: '检验人 ',
      type: 'String'
    },
    {
      value:'inspectDt',
      text: '检验时间 ',
      type: 'String'
    },
    {
      value:'planExpedited',
      text: '是否加急',
      type: 'select',
      dictCode: ''
    },
    {
      value:'verifyTimes',
      text: '检验次数',
      type: 'int'
    },
    {
      value:'inspectStatus',
      text: '检验状态',
      type: 'select',
      dictCode: 'mes_into_inspect_status'
    },
    {
      value:'inspectResult',
      text: '检验结果',
      type: 'select',
      dictCode: 'mes_into_inspect_result'
    },
    {
      value:'mrb',
      text: 'MRB',
      type: 'string'
    },
    {
      value:'attachmentUrl',
      text: '附件',
      type: 'String'
    },
    {
      value:'inspectConclusion',
      text: '检验结论',
      type: 'string'
    },
    {
      value:'mrbPlayno',
      text: 'MRB放行单号',
      type: 'select',
      dictCode: ''
    },
    {
      value:'createBy',
      text: '创建人',
      type: 'string'
    },
    {
      value:'createTime',
      text: '创建日期',
      type: 'Date'
    },
    {
      value:'updateBy',
      text: '更新人',
      type: 'string'
    },
    {
      value:'updateTime',
      text: '更新日期',
      type: 'Date'
    },
    {
      value:'remark',
      text: '备注',
      type: 'string'
    },
  ]

  export default {
    name: "MesQcDeliveryInspectTaskList",
    mixins:[JeecgListMixin],
    components: {
      TesttableList,
      JSuperQuery,
      MesQcDeliInspectItemList,
      MesQcDeliInspectProductListList,
      FxCompontensModal,
      MesQcDeliveryInspectTaskModal
    },
    props:['reload','childId','pageState'],
    data () {

      return {




        fieldList:superQueryFieldList,
        superQueryFlag:false,
        superQueryParams: '',
        description: '出厂检验任务清单管理页面',
        EnhanceJS:'',
        cgButtonLinkList:[],
        cgButtonList:[],
        title:'',//存表名
        groupTag:[],
        queryInfo: [],
        code: '',

        baseInfoData:{},
        drawerVisible:false,
        activeKey:['1'],
        phUpVisible2:false,
        reviewVisible:false,
        dPhVisible:false,
        dPhUrl:'',
        currentD:{},
        currentDetailPhObj:'',

        rowId:0,

        inspectionProductsColumns: [
          { title: "序号",
            dataIndex: "",
            key: "rowIndex",
            width: 60,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }, },
          { title: "线体", dataIndex: "linename", key: "linename" },
          {
            title: "生产工单",
            dataIndex: "productionno",
            key: "productionno",
          },
          { title: "工序工单", dataIndex: "processbillno", key: "processbillno" },
          { title: "产品编码", dataIndex: "mcode", key: "mcode" },
          { title: "产品名称", dataIndex: "mname", key: "mname" },
          { title: "栈板号/容器码", dataIndex: "palletNo", key: "palletNo" },
          { title: "SN/PN", dataIndex: "snpn", key: "snpn" },
          { title: "数量", dataIndex: "qty", key: "qty",scopedSlots: {customRender: "qty"} },
          { title: "状态", dataIndex: "status", key: "status",
            customRender: (text) => {
              if (!text) {
                return "";
              } else {
                return text==1?'未检':'已检';
              }
            },
          },
        ],

        modal1InspectionColumns: [
          {
            title: "序号",
            dataIndex: "",
            key: "rowIndex",
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            },
          },
          { title: "线号/组件编号", dataIndex: "lineBillno", key: "lineBillno" },
          {
            title: "产品编码",
            dataIndex: "mcode",
            key: "mcode",
          },
          {
            title: "产品名称",
            dataIndex: "mname",
            key: "mname",
          },
          { title: "产品小类", dataIndex: "msmall", key: "msmall" },
          { title: "产品大类", dataIndex: "mbig", key: "mbig" },
          { title: "检验结果", dataIndex: "inspectResult", key: "inspectResult" },
          {
            title: "图片",
            dataIndex: "photoUrl",
            key: "photoUrl",
            scopedSlots: { customRender: "photoUrl" },
          },
        ],


        modal1InspectionInnerColumns: [
          {
            title: "序号",
            dataIndex: "",
            key: "rowIndex",
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            },
          },

          { title: "检验项目", dataIndex: "inspectItem", key: "inspectItem" },
          {
            title: "检验标准",
            dataIndex: "inspectStandard",
            key: "inspectStandard",
          },
          {
            title: "值类型",
            key: "valueType",
            dataIndex: "valueType",
            customRender:function(value){

              return value?value==1?"计数型":"计量型":"";
            }
          },
          { title: "标准值", dataIndex: "standardValue", key: "standardValue" },
          {
            title: "上限值",
            dataIndex: "upperValue",
            key: "upperValue",

          },
          { title: "下限值", dataIndex: "downValue", key: "downValue" },
          { title: "参数", dataIndex: "param", key: "param" },
          {
            title: "实测值",
            dataIndex: "measuredValue",
            key: "measuredValue",

          },
          {
            title: "单项判定",
            dataIndex: "individualJudgment",
            key: "individualJudgment",
            customRender:function(value){

              return value?value==1?"PASS":"NG":"";
            }
          },


        ],

        // 表头
        columns: [],
        //列设置
        settingColumns:[],
        //列定义
        defColumns: [
          {
            title: "序号",
            dataIndex: "",
            key: "rowIndex",
            width: 10,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            },
          },
          {
            title: '送检单号',
            align: 'center',
            dataIndex: 'inspectBillno',
            scopedSlots: { customRender: 'inspectBillno' },
          },
          {
            title: '产品编号',
            align: 'center',
            dataIndex: 'mcode',
          },
          {
            title: '产品名称',
            align: 'center',
            dataIndex: 'mname',
          },
          {
            title: '送检方式',
            align: 'center',
            dataIndex: 'inspectMethod',
          },
          {
            title: '物料属性',
            align: 'center',
            dataIndex: 'mProperty',
          },
          {
            title: '发货工单号',
            align: 'center',
            dataIndex: 'deliveryNumber',
          },
          {
            title: '送检数量',
            align: 'center',
            dataIndex: 'inspectQty',
          },

          {
            title: '抽检数量',
            align: 'center',
            dataIndex: 'samplingQty',
          },
          {
            title: '是否加急',
            align: 'center',
            dataIndex: 'planExpedited',
            scopedSlots: {customRender: 'planExpedited'},
          },
          {
            title: '检验次数',
            align: 'center',
            dataIndex: 'verifyTimes',
          },
          {
            title: '送检时间',
            align: 'center',
            dataIndex: 'sendInspectDt',
            customRender:function (text) {
              return text;
            },
          },
          {
            title: '检验剩余时长(分钟)',
            align: 'center',
            dataIndex: 'remainingTime',
          },
          {
            title: '送检人',
            align: 'center',
            dataIndex: 'sender',
          },

          {
            title: '检验状态',
            align: 'center',
            dataIndex: 'inspectStatus',
            scopedSlots: {customRender: 'inspectStatus'},
          },
          {
            title: '检验结果',
            align: 'center',
            dataIndex: 'inspectResult',
            scopedSlots: {customRender: 'inspectResult'},
          },
          {
            title: 'MRB',
            align: 'center',
            dataIndex: 'mrbPlayno',
          },
          /*{
            title: '检验结论',
            align: 'center',
            dataIndex: 'inspectConclusion',
          },*/
          /*{
            title: 'MRB放行单号',
            align: 'center',
            dataIndex: 'mrbPlayno',
            customRender:(text)=>{
              if(!text){
                return ''
              }else{
                return filterMultiDictText(this.dictOptions['mrbPlayno'], text+"")
              }
            },
          },*/
          /*{
            title: '创建人',
            align: 'center',
            dataIndex: 'createBy',
          },
          {
            title: '创建日期',
            align: 'center',
            dataIndex: 'createTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            },
          },
          {
            title: '更新人',
            align: 'center',
            dataIndex: 'updateBy',
          },
          {
            title: '更新日期',
            align: 'center',
            dataIndex: 'updateTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            },
          },
          {
            title: '备注',
            align: 'center',
            dataIndex: 'remark',
          },*/

        ],
        url: {
          list: '/mes-quality/mesQcDeliveryInspectTask/list',
          delete: '/mes-quality/mesQcDeliveryInspectTask/delete',
          deleteBatch: '/mes-quality/mesQcDeliveryInspectTask/deleteBatch',
          exportXlsUrl: '/mes-quality/mesQcDeliveryInspectTask/exportXls',
          importExcelUrl: '/mes-quality/mesQcDeliveryInspectTask/importExcel',
          getColumns: '/mes-quality/online/cgform/api/getColumns/',
          buttonAction: '/mes-quality/online/cgform/api/doButton',
        },
        dictOptions:{
          planExpedited:[],
          inspectStatus:[],
          inspectResult:[],
          mrbPlayno:[],
        },
        /* 分页参数 */
        ipagination:{
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '50'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        selectedMainId:''

      }
    },
    computed: {
      importExcelUrl: function(){
        return `${api.test}${this.url.importExcelUrl}`;
      },
      getWidth:function(){
        if(this.defColumns.length > 14){
          return {width : '500px'}
        }
      },
      newSelectedMainId:function(){
        if(typeof(this.selectedMainId) == 'number'){
          return this.selectedMainId.toString()
        }else{
          return this.selectedMainId
        }
      },
      tableScroll:function(){
        if(this.columns.length > 13){
          return { x: this.columns.length*150-450 }
        }
      }
    },

    created() {
      this.reloadListener();
      this.initButtonList();
      this.initColumns();
      this.setdefColumns();
    },



    methods: {

      reloadListener(){
        if(this.reload){
          this.loadData();
        }
      },

      //确定按钮
      handleSearch(selectedKeys, confirm, dataIndex) {
        confirm();
        this.searchText = selectedKeys[0];
        this.searchedColumn = dataIndex;
      },
      //取消按钮
      handleReset(clearFilters) {
        clearFilters();
        this.searchText = '';
      },

      drawerClose(){
        this.drawerVisible=false;
        this.activeKey=['1'];
      },

      expandIconOne(props){
        if(props.record.mesQcInspectProjectsList&&props.record.mesQcInspectProjectsList.length>0){

          if (props.expanded) {
            return <p-icon type='minus-square' onClick={e => {props.onExpand(props.record, e);}}/>;
          }else{
            return <p-icon type='plus-square' onClick={e => {props.onExpand(props.record, e);}}/>;
          }

        }else{
          return "";
        }
      },

      //确定时间
      handleSearchDate(selectedKeys, confirm, dataIndex){
        confirm();
        this.searchText = selectedKeys[0];
        this.searchedColumn = dataIndex;
        this.searchQuery()
      },
      // 清除时间
      handleResetDate(clearFilters,begin,end) {
        if(this.queryParam[begin] || this.queryParam[end]){
          this.queryParam[begin] = ''
          this.queryParam[end] = ''
          clearFilters();
          this.searchText = '';
          this.searchQuery()
        }else{
          clearFilters();
          this.searchText = '';
        }

      },
      getKey () {
        const dataItem = []
        setTimeout(() => {
          this.columns.forEach(item => {
            dataItem.push({ 'text': item.title, 'value': item.dataIndex })
          })
        }, 100)
        return dataItem
      },
      //
      getControl (dic) {
        const dataItem = []
        initDictOptions(dic).then((res) => {
          res.data.forEach(item => {
            dataItem.push({ 'text': item.text, 'value': item.value })
          })
        })
        return dataItem
      },
      openPhReviewBtn2(record){
        this.dPhVisible = true;
        let obj = JSON.parse(record.photoUrl);
        this.dPhUrl = obj[0].filePath;
      },

      phUpSave2(){
        let data = {
          id:this.currentD.id,
          photoUrl:this.currentDetailPhObj
        }

        let r = this.currentD;
        postAction('/mes-quality/mesQcTourInspectTask/updateInspectProject',data).then(res=>{
          if(res.success){
            this.$message.success('操作成功!');
            this.phUpVisible2 = false;
            this.baseInfoData.mesQcTourinspLinemList[r.fKey-1].mesQcTourinspProjectsList[r.key-1].photoUrl = this.currentDetailPhObj;
          }else{
            this.$message.warning(res.msg)
          }
        })
      },
      setdefColumns(){
        if(this.columns.length > 13){
          let arrLength = this.columns.length-1
          this.columns.forEach((item,index)=>{
            item["width"] = 130
          })
          this.columns[arrLength]['fixed'] = 'right'
          this.columns[arrLength-1]['fixed'] = 'right'
          this.columns[arrLength-2]['fixed'] = 'right'
          this.columns[0]['fixed'] = 'left'
          this.columns[1]['fixed'] = 'left'
        }
      },
      initColumns(){
        //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
        //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');

        var key = this.$route.name+":colsettings";
        let colSettings= Vue.ls.get(key);
        if(colSettings==null||colSettings==undefined){
          let allSettingColumns = [];
          this.defColumns.forEach(function (item,i,array ) {
            allSettingColumns.push(item.dataIndex);
          })
          this.settingColumns = allSettingColumns;
          this.columns = this.defColumns;
        }else{
          this.settingColumns = colSettings;
          const cols = this.defColumns.filter(item => {
            if(item.key =='rowIndex'|| item.dataIndex=='action'){
              return true;
            }
            if (colSettings.includes(item.dataIndex)) {
              return true;
            }
            return false;
          })
          this.columns =  cols;
        }
      },
      //列设置更改事件
      onColSettingsChange (checkedValues) {
        var key = this.$route.name+":colsettings";
        Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
        this.settingColumns = checkedValues;
        const cols = this.defColumns.filter(item => {
          if(item.key =='rowIndex'|| item.dataIndex=='action'){
            return true
          }
          if (this.settingColumns.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns =  cols;
      },
      //高级查询方法
      handleSuperQuery(arg) {
        if(!arg){
          this.superQueryParams=''
          this.superQueryFlag = false
        }else{
          this.superQueryFlag = true
          this.superQueryParams=JSON.stringify(arg)
        }
        this.loadData()
      },
      // 获取查询条件
      getQueryParams() {
        let sqp = {}
        if(this.superQueryParams){
          sqp['superQueryParams']=encodeURI(this.superQueryParams)
        }
        var param = Object.assign(sqp, this.queryParam, this.isorter);
        param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.limit = this.ipagination.pageSize;

        return filterObj(param);
      },
      initDictConfig(){
        initDictOptions('').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'planExpedited', res.data)
          }
        })
        initDictOptions('mes_into_inspect_status').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'inspectStatus', res.data)
          }
        })
        initDictOptions('mes_into_inspect_result').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'inspectResult', res.data)
          }
        })
        initDictOptions('').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'mrbPlayno', res.data)
          }
        })
      },
      clickThenSelect(record, index) {
        return {
          on: {
            click: () => {
              this.rowId = record.id;

            },

            dblclick: () => {

              let id = record.id;
              getAction('/mes-quality/mesQcDeliveryInspectTask/selectDeliveryInspectTask/'+id).then(res=>{
                if (res.success) {
                  this.drawerVisible=true;
                  let data = res.data;
                  this.baseInfoData = data;

                } else {
                  this.$message.warning("后台获取单据信息报错");
                }
              })

            },
          },
        };
      },

      setRowClassName(record){
        if(record.id===this.rowId){
          if(record.remainingTime<=0){
            if(record.inspectStatus==4){
              return 'clickRowStyl';
            }else{
              return 'clickRowStyl3';
            }

          }else{
            return 'clickRowStyl';
          }
        }else{
          if(record.remainingTime<=0&&record.inspectStatus!=4){
            return 'clickRowStyl2';
          }
        }

      },

      onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
        this.selectedMainId=''
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedMainId=selectedRowKeys[0]
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
      },
      loadData(arg) {

        console.log(123)
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        this.onClearSelected()
        var params = this.getQueryParams();//查询条件
        console.log(params)
        params.column='planExpedited'
                params.order='asc'

        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.data.records;
            this.ipagination.total = res.data.total;
          }
          if(res.code===510){
            this.$message.warning(res.msg)
          }

        }).then(res=>{
          this.loading = false;
        })
      },

      // 弹出窗组件
      showDemoModal() {
        this.$refs.modalCompon.modalShow();
      },
      // 点击btn获取数据
      btnGetData(tableName,title){
        getAction(`${this.url.getColumns}`,{
          tableName:tableName
        }).then(
                res=>{
                  if(res.code == 0){
                    this.queryInfo = res.data.columns
                    this.title = title
                    this.dictOptions = res.data.dictOptions
                    this.showDemoModal()
                  }else{
                    this.$message.warning(res.msg);
                  }
                }
        )
      },

      //筛选分组
      getGroupTag(arrList) {
        let arr = [];
        var map = {},
                dest = [];
        arrList.forEach((item, index) => {
          if (item.groupTag) {
            arr.push(item);
          }
        });
        for (var i = 0; i < arr.length; i++) {
          var ai = arr[i];
          if (!map[ai.groupTag]) {
            dest.push({
              groupTag: ai.groupTag,
              name: ai.groupName,
              data: [ai]
            });
            map[ai.groupTag] = ai;
          } else {
            for (var j = 0; j < dest.length; j++) {
              var dj = dest[j];
              if (dj.groupTag == ai.groupTag) {
                dj.data.push(ai);
                break;
              }
            }
          }
        }
        this.groupTag = dest
        console.log(dest);
      },
      showLinkButton(item,record){
        let btn = new ButtonExpHandler(item.exp,record);
        return btn.show;
      },
      initButtonList(){
        getAction(`${this.url.getColumns}8ac49ec7733bce4801734647471e00a9`).then((res)=>{
          console.log("--获取自定义按钮->>",res);
          if(res.success){
            this.code = res.data.code;
            this.initCgButtonList(res.data.cgButtonList);
            this.initCgEnhanceJs(res.data.enhanceJs);
            this.getGroupTag(res.data.cgButtonList);
          }else{
            this.$message.warning(res.msg)
          }
        })
      },
      initCgEnhanceJs(enhanceJs){
        //console.log("--onlineList-js增强",enhanceJs)
        if(enhanceJs){
          let Obj = eval ("(" + enhanceJs + ")");
          this.EnhanceJS = new Obj(getAction,postAction,deleteAction);
          this.cgButtonJsHandler('created')
        }else{
          this.EnhanceJS = ''
        }
      },
      initCgButtonList(btnList){
        let linkArr = []
        let buttonArr = []
        if(btnList && btnList.length>0){
          for(let i=0;i<btnList.length;i++){
            let temp = btnList[i]
            if(temp.buttonStyle=='button'){
              buttonArr.push(temp)
            }else if(temp.buttonStyle=='link'){
              linkArr.push(temp)
            }
          }
        }
        this.cgButtonLinkList = [...linkArr]
        this.cgButtonList=[...buttonArr]
        console.log("链接增强", this.cgButtonLinkList);
      },
      cgButtonJsHandler(buttonCode){
        if(this.EnhanceJS[buttonCode]){
          this.EnhanceJS[buttonCode](this)
        }
      },
      cgButtonActionHandler(buttonCode){
        //处理自定义button的 需要配置该button自定义sql
        if(!this.selectedRowKeys || this.selectedRowKeys.length==0){
          this.$message.warning("请先选中一条记录")
          return false
        }
        if(this.selectedRowKeys.length>1){
          this.$message.warning("请只选中一条记录")
          return false
        }
        let params = {
          formId:this.code,
          buttonCode:buttonCode,
          dataId:this.selectedRowKeys[0]
        }
        console.log("自定义按钮请求后台参数：",params)
        postAction(this.url.buttonAction,params).then(res=>{
          if(res.success){
            this.loadData()
            this.$message.success("处理完成!")
          }else{
            this.$message.warning("处理失败!")
          }
        })

      },
      cgButtonLinkHandler(record,buttonCode,optType){
        if(optType=="js"){
          if(this.EnhanceJS[buttonCode]){
            this.EnhanceJS[buttonCode](this,record)
          }
        }else if(optType=="action"){
          let params = {
            formId:this.code,
            buttonCode:buttonCode,
            dataId:record.id
          }
          console.log("自定义按钮link请求后台参数：",params)
          postAction(this.url.buttonAction,params).then(res=>{
            if(res.success){
              this.loadData()
              this.$message.success("处理完成!")
            }else{
              this.$message.warning("处理失败!")
            }
          })
        }
      },

      changePlanExpedited(id){

        getAction('/mes-quality/mesQcDeliveryInspectTask/urgent/'+id).then(res=>{
          if (res.success) {
            this.loadData();
            this.$message.success("处理完成!");
          } else {
            this.$message.warning(res.msg);
          }
        })
      },


      inspectBillnoClick(record){
        let id = record.id;
        let inspectStatus = record.inspectStatus;
        switch (inspectStatus) {
          case 1:
            /*this.$router.push({path:"/work/auto/MesQcDeliveryOperation",query:{id:id}})*/
            this.$emit('update:childId', id);
            this.$emit('update:reload', true);
            this.$emit('update:pageState', 2);
          case 2:
            /*this.$router.push({path:"/work/auto/MesQcDeliveryOperation",query:{id:id}})*/
            this.$emit('update:childId', id);
            this.$emit('update:reload', true);
            this.$emit('update:pageState', 2);

            break;
            break;
          default:
            break;
        }
      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  /deep/.clickRowStyl td{
    background:#00b4ed !important;
  }
  /deep/.clickRowStyl2 td{
    color:red;
  }

  /deep/.clickRowStyl3 td{
    background:#00b4ed !important;
    color:red;
  }

  /deep/.ant-table-tbody.clickRowStyl:hover>td {
    background-color:#00b4ed
  }
  .myImg{
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
  }
</style>
